{% extends "domain_base.html" %}
{% block domain_content %}
<div style="display: none" class="dialog__body--create-role">
  <div>
    <div class="row"><div class="columns">
      <h1>{{ _('Create Role') }}</h1>
    </div></div>
    <div class="row"><div class="columns">
      <blockquote class="note">
        <p>{{ _('Role name can only contains numbers, letters and underscores.') }}</p>
      </blockquote>
      {{ form.form_text(columns=None, label='Name', name='role', autofocus=True) }}
    </div></div>
  </div>
</div>
<div class="section">
  <div class="section__header">
    <h1 class="section__title">{{ _('{0}: Roles').format(handler.domain['name']) }}</h1>
    <div class="section__tools">
      <button class="primary rounded button" name="create_role">{{ _('Create Role') }}</button>
    </div>
  </div>
  {{ noscript_note.render() }}
  <div class="section__body no-padding domain-roles">
    <table class="data-table">
      <colgroup>
        <col class="col--checkbox">
        <col class="col--id">
        <col class="col--description">
        <col class="col--users">
      </colgroup>
      <thead>
        <tr>
          <th class="col--checkbox">
            <label class="compact checkbox">
              <input type="checkbox" data-checkbox-toggle="role">
            </label>
          </th>
          <th class="col--id">{{ _('Role') }}</th>
          <th class="col--description">{{ _('Description') }}</th>
          <th class="col--users">{{ _('Users') }}</th>
        </tr>
      </thead>
      <tbody>
      {% for role, rd in vj4.model.builtin.BUILTIN_ROLE_DESCRIPTORS.items() %}
        <tr>
          <td class="col--checkbox">
            <label class="compact checkbox">
              <input type="checkbox" data-checkbox-group="role" disabled>
            </label>
          </td>
          <td class="col--id">
            {{ role }}
          </td>
          <td class="col--description">
            {{ _('Built-in') }}: {{ _(rd.description) }}
          </td>
          <td class="col--users">
            {{ rucounts.get(role, '--') }}
          </td>
        </tr>
      {% endfor %}
      {% for role in roles %}
      {% if role not in vj4.model.builtin.BUILTIN_ROLE_DESCRIPTORS %}
        <tr data-role="{{ role }}">
          <td class="col--checkbox">
            <label class="compact checkbox">
              <input type="checkbox" data-checkbox-group="role" data-checkbox-range>
            </label>
          </td>
          <td class="col--id">
            {{ role }}
          </td>
          <td class="col--description">
            {{ _('User-defined role') }}
          </td>
          <td class="col--users">
            {{ rucounts[role] }}
          </td>
        </tr>
      {% endif %}
      {% endfor %}
      </tbody>
    </table>
  </div>
  <div class="section__body">
    <button class="rounded button" name="delete_selected">{{ _('Delete Selected Roles') }}</button>
  </div>
</div>
{% endblock %}
